package com.jxdinfo.hussar.example.cgmk.materialpurchase1.controller;

import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jxdinfo.hussar.support.audit.core.annotations.AuditLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventGrade;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Arrays;
import com.jxdinfo.hussar.example.cgmk.materialpurchase1.model.MaterialPurchase1;
import com.jxdinfo.hussar.example.cgmk.materialpurchase1.service.MaterialPurchase1Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.beans.factory.annotation.Autowired;
import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;

/**
 * 采购信息表1控制器
 */
@RestController(value = "cgmk.materialpurchase1.MaterialPurchase1Controller")
@RequestMapping(value = "/cgmk/materialPurchase1")
@AuditLog(moduleName = "采购信息表1")
@Api(tags = "采购信息表1控制器")
public class MaterialPurchase1Controller {

    private static final Logger logger = LoggerFactory.getLogger(MaterialPurchase1Controller.class);

    @Autowired
    private MaterialPurchase1Service materialPurchase1Service;

    /**
     * 采购信息表1表单查询
     */
    @AuditLog(moduleName = "采购信息表1", eventDesc = "表单查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @GetMapping("formQuery")
    public ApiResponse<MaterialPurchase1> formQuery(@RequestParam(value = "id") String id) {
        return materialPurchase1Service.formQuery(id);
    }

    /**
     * 采购信息表1物理删除主子
     */
    @PostMapping(value = "/del")
    @AuditLog(moduleName = "采购信息表1", eventDesc = "批量物理删除", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.DELETE)
    public ApiResponse<Boolean> del(@RequestParam(value = "ids") String[] ids) {
        return materialPurchase1Service.del(Arrays.asList(ids));
    }

    /**
     * 采购信息表1新增或修改
     */
    @AuditLog(moduleName = "采购信息表1", eventDesc = "新增或修改", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.INSERT)
    @PostMapping("insertOrUpdate")
    public ApiResponse<String> insertOrUpdate(@RequestBody MaterialPurchase1 materialPurchase1) {
        return materialPurchase1Service.insertOrUpdate(materialPurchase1);
    }
}
